/**
 * 
 */
package com.jbarreto.vc.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * @author Administrador
 *
 */
public class RegistrationForm extends ActionForm {

	private static final long serialVersionUID = 3063518731280311253L;
	
	private String email 	= null;
	private String password = null;
	
	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		
		this.email 		= null;
		this.password 	= null;
	}

	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();

		if (getEmail() == null || getEmail().length() < 1) {
			errors.add("email", new ActionMessage("error.email.required"));
		}
		if (getPassword() == null || getPassword().length() < 1) {
			errors.add("password", new ActionMessage("error.password.required"));
		}

		return errors;
	}
}
